package com.infolab.aims.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.validator.constraints.NotBlank;

import com.infolab.aims.common.SpecialToStringStyle;
import com.infolab.aims.common.bean.AbstractModelBean;

@Entity
@Table(name = "AMTB_DEPARTMENT")
public class Department extends AbstractModelBean implements Serializable {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer departmentId;

	@NotBlank(message = "{error.empty}")
	private String departmentCode;

	@NotBlank(message = "{error.empty}")
	private String departmentName;

	@NotBlank(message = "{error.empty}")
	private String departmentUnitNo;

	private String departmentContact;

	@Column(columnDefinition = "number(1,0) default 1 not null")
	private boolean active;

	public Integer getDepartmentId() {
		return departmentId;
	}

	public void setDepartmentId(Integer departmentId) {
		this.departmentId = departmentId;
	}

	public String getDepartmentCode() {
		return departmentCode;
	}

	public void setDepartmentCode(String departmentCode) {
		this.departmentCode = departmentCode;
	}

	public String getDepartmentName() {
		return departmentName;
	}

	public void setDepartmentName(String departmentName) {
		this.departmentName = departmentName;
	}

	public boolean isActive() {
		return active;
	}

	public void setActive(boolean active) {
		this.active = active;
	}

	public String getAuditContentHead() {

		return new ToStringBuilder(this, SpecialToStringStyle.SPECIAL_STYLE).append("Company. Code ", departmentCode)
				.append("Company. Name ", departmentName).append("Company. Unit ", departmentUnitNo).toString();
	}

	public String getAuditContentDetail() {
		return super.getAuditContentDetail();
	}

	public String getAuditCode() {
		if (StringUtils.isNotEmpty(departmentCode)) {
			return departmentCode;
		}
		return super.getAuditCode();
	}

	public String getDepartmentUnitNo() {
		return departmentUnitNo;
	}

	public void setDepartmentUnitNo(String departmentUnitNo) {
		this.departmentUnitNo = departmentUnitNo;
	}

	public String getDepartmentContact() {
		return departmentContact;
	}

	public void setDepartmentContact(String departmentContact) {
		this.departmentContact = departmentContact;
	}

}
